import static org.junit.Assert.*;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.zanateh.wargame.game.*;
import org.zanateh.wargame.game.util.Coordinate;

public class CoordinateTest {
	@Test
	public void testCoordinateCreation() {
		Coordinate coord = new Coordinate(2, 3);
		Assert.assertEquals( 2, coord.getCol());
		Assert.assertEquals( 3, coord.getRow());
	}
	
	@Test
	public void testAdjancencyOddCol() {
		Coordinate coord = new Coordinate(1,1);
		
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(1,0)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(1,2)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(0,1)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(0,2)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(2,1)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(2,2)));
		
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(0,0)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(2,0)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(0,3)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(1,3)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(2,3)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(3,1)));
	}
	
	@Test
	public void testAdjancencyEvenCol() {
		Coordinate coord = new Coordinate(2,1);
		
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(2,0)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(2,2)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(1,0)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(1,1)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(3,0)));
		Assert.assertTrue(coord.isAdjacentTo(new Coordinate(3,1)));
		
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(0,0)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(0,1)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(1,2)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(2,3)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(3,2)));
		Assert.assertFalse(coord.isAdjacentTo(new Coordinate(4,1)));
	}

	
}
